package telas;

import javax.swing.BorderFactory;
import utilitarios.Bounds;
import javax.swing.JLabel;
import javax.swing.JPanel;
import telas.cadastros.ClienteFisico;
import telas.cadastros.SituacaoQuarto;
import telas.cadastros.TipoQuarto;
import utilitarios.IconeQuarto;

/**
 *
 * @author WELISSON
 */
public class Principal extends javax.swing.JFrame {

    Bounds bounds = new Bounds();
    JPanel painel;
    /**
     * Creates new form Principal
     */
    public Principal() {
        setUndecorated(true);//retira barra de titulo.
        initComponents();
        setLocationRelativeTo(null);
        telaInteira();
        fecharMinimizar();
        painel = new JPanel();
        inserePainel();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/1396598872_cog-icon-2-48x48.png"))); // NOI18N
        jMenu1.setText("Opções");

        jMenu3.setText("Cadastro");

        jMenuItem1.setText("Cliente Físico");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem1);

        jMenuItem2.setText("Quarto");
        jMenu3.add(jMenuItem2);

        jMenuItem3.setText("Situação do Quarto");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem3);

        jMenuItem4.setText("Tipo de Quarto");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem4);

        jMenu1.add(jMenu3);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Consulta");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 665, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 293, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        ClienteFisico cFisico = new ClienteFisico(this, true);
        cFisico.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        SituacaoQuarto situacaoQuarto = new SituacaoQuarto(this, true);
        situacaoQuarto.setVisible(true);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        TipoQuarto tipoQuarto = new TipoQuarto(this,true);
        tipoQuarto.setVisible(true);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Principal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    // End of variables declaration//GEN-END:variables

    private void telaInteira() {
        bounds.setAllScreenBounds(this);
        this.setBounds(bounds.left, bounds.top, bounds.width, bounds.height);
    }

    private void fecharMinimizar() {

        JLabel fechar = bounds.botaoFechar(this.getWidth(), this);
        JLabel minimizar = bounds.botaoMinimizar(this.getWidth(), this);
        this.add(fechar);
        this.add(minimizar);

    }
    private void inserePainel(){
        int xTela = this.getWidth();
        int yTela = this.getHeight();
        int xPos = (xTela - (xTela-100))/2;
        int yPos = (yTela - (yTela-100))/2;
        painel.setBounds(xPos, yPos, xTela-100, yTela-100);
        painel.setBorder(BorderFactory.createTitledBorder("Quartos"));
        //painel.setBackground(Color.BLACK);
        
        this.add(painel);
        insereQuarto();
    }
    private void insereQuarto() {
        IconeQuarto quartos = new IconeQuarto();
        int x = 100;
        int y = 100;
        for ( int i = 0; i < 50; i++ ) {
            if(x == 500){
                y += 100;
                x = 100;
            }
            JLabel quarto = quartos.setaQuarto(x, y);
            painel.add(quarto);
            
            x += 100;
        }
    }
}
